package com.rylan.controller;

import com.rylan.repository.AdminRepository;
import com.rylan.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author rylan
 * @description
 */
@RestController
@RequestMapping("/account")
public class AccountController {
    @Autowired
    private UserRepository userRepository;
    @Autowired
    private AdminRepository adminRepository;
    @GetMapping("/login/{username}/{password}/{type}")
    public Object login(@PathVariable("username") String username, @PathVariable("password") String password, @PathVariable("type") String type){
        Object o = null;
        switch (type){
            case "user":
                o = userRepository.login(username, password);
                break;
            case "admin":
                o = adminRepository.login(username, password);
                break;
        }
        return o;
    }
}
